package com.gpnu.crm.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;
import com.gpnu.crm.domain.CustomerTraceHistory;
import com.gpnu.crm.domain.Employee;
import com.gpnu.crm.query.CustomerTraceHistoryQueryObject;
import com.gpnu.crm.service.ICustomerTraceHistoryService;
import com.gpnu.crm.service.ISystemDictionaryService;
import com.gpnu.crm.util.UserContext;


@Controller
@RequestMapping("/customerTraceHistory")
public class CustomerTraceHistoryController {
	
	@Autowired
	private ICustomerTraceHistoryService customerTraceHistoryService;
	@Autowired
	  private ISystemDictionaryService dictionaryService;
	
	@RequestMapping("/list")
	public String list(@ModelAttribute("qo") CustomerTraceHistoryQueryObject qo, Model model) {
		PageInfo<CustomerTraceHistory> info = customerTraceHistoryService.query(qo);
		model.addAttribute("pageInfo", info);	
		model.addAttribute("types", dictionaryService.queryItemByParentSn("communicationMethod"));
		return "customerTraceHistory/list";
	}
	
	@RequestMapping("/saveOrUpdate")
	public String saveOrUpdate(CustomerTraceHistory customerTraceHistory) {
		//Employee loginUser = UserContext.getCurrentUser();
		//customerTraceHistory.setInputUser(loginUser);
		customerTraceHistoryService.saveOrUpdate(customerTraceHistory);
		return "redirect:/customerTraceHistory/list.do";
	}

}
